version: "3.8"

services:

  cbot:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "${APP_PORT}:${APP_PORT}"
    env_file:
      - ./build/.env
    environment:
      - LOG_PATH=/logs
      - SPRING_DATASOURCE_URL=jdbc:postgresql://cbot-pg:5432/${POSTGRES_DB?DbNameNotProvided}
      - SPRING_DATASOURCE_USERNAME=${POSTGRES_USER?dbUserNameNotProvided}
      - SPRING_DATASOURCE_PASSWORD=${POSTGRES_PASSWORD?dbPasswordNotProvided}
      - SPRING_PROFILES_ACTIVE=prod
      - BOT_NAME=${C_BOT_NAME}
      - BOT_TOKEN=${C_BOT_TOKEN}
      - BOT_ADMINID=${BOT_ADMIN}
      - BOT_CHAT-INTERVAL=60000
      - BOT_MAX-MESSAGES=14
      - BOT_CAPTION-LENGTH=1024
    depends_on:
      - cbot-pg
    networks:
      - cbot-pg
    volumes:
      - ./logs:/logs

  cbot-pg:
    container_name: cbot-pg
    image: "postgres:16"
    restart: unless-stopped
    env_file:
      - ./build/.env
    environment:
      - POSTGRES_DB=${POSTGRES_DB}
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
    ports:
      - "5432:5432"
    networks:
      - cbot-pg
    volumes:
      - /var/docker-volumes/cbot-pg:/var/lib/postgresql/data/

networks:
  cbot-pg:
    driver: bridge

